<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" isELIgnored="false" import="java.util.*"
	pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@page import="com.opensymphony.xwork2.ActionContext"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="<%=request.getContextPath()%>/fare/css/base.css"
	rel="stylesheet" type="text/css" />
<%-- <script type="text/javascript" src="${pageContext.request.contextPath}/fare/js/show.js"></script>--%>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/fare/js/jquery-1.6.4.min.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/fare/js/datePicker/WdatePicker.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/fare/lib/ligerUI/js/ligerui.min.js"></script>
<link
	href="<%=request.getContextPath()%>/fare/lib/ligerUI/skins/Aqua/css/ligerui-all.css"
	rel="stylesheet" type="text/css" />
<%-- <link
	href="<%=request.getContextPath()%>/fare/lib/ligerUI/skins/Gray/css/all.css"
	rel="stylesheet" type="text/css" /> --%>
<link
	href='<%=request.getContextPath()%>/fare/js/cityquery/cityquery.css'
	rel="stylesheet" type="text/css" />
<script type="text/javascript"
	src="<%=request.getContextPath()%>/jsFile/common.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/jsFile/multiblepicker.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/jsFile/FDCDialog.js"></script>

<script type='text/javascript'
	src='<%=request.getContextPath()%>/fare/js/cityquery/citylist.js'></script>
<script type='text/javascript'
	src='<%=request.getContextPath()%>/fare/js/cityquery/querycity.js'></script>

<link rev="stylesheet" media="all"
	href="<%=request.getContextPath()%>/fare/css/form_style.css"
	type="text/css" rel="stylesheet">
	<script type="text/javascript"
		src="<%=request.getContextPath()%>/jsFile/fdc.js"></script>
	<!-- 圆角文本框 -->
	<link href="<%=request.getContextPath()%>/fare/css/htc/htc.css"
		rel="stylesheet" type="text/css" />
	<script type="text/javascript">
var grid;
function currentDate(){ 
    var now = new Date();       
    var year = now.getFullYear();
    var month = now.getMonth() + 1;
    var day = now.getDate();
    var hour = now.getHours();
    var min = now.getMinutes();
    var second = now.getSeconds();
    var today = year + "-";       
    if(month < 10)
        today += "0";       
    today += month + "-";       
    if(day < 10)
        today += "0";           
    today += day;
    today += " ";
    today += hour;
    today += ":"; 
    today += min;
    today += ":"; 
    today += second; 
    return(today); 
} 
function   formatDate(now)   {   
    var   year=now.getFullYear();   
    var   month=now.getMonth()+1;   
    var   date=now.getDate();   
    var   hour=now.getHours();   
    var   minute=now.getMinutes();   
    var   second=now.getSeconds();   
    return   year+"-"+month+"-"+date+"   "+hour+":"+minute+":"+second;   
    } 
function getLocalTime(nS) {   
	   return new Date(parseInt(nS) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");    
	}      
    
$(function(){
	$('#depCity').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});
	$('#arrCity').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});
	if($('#grapDate').val()==''){
		$('#grapDate').val(currentDate());
	}	
	if($('#depTime').val()==''){
		$('#depTime').val(currentDate());
	}
	var grid=$("#maingrid").ligerGrid({
        enabledSort:true,    // 就否允许排序
        usePager:true,
        isScroll:true,
		columns: [
	               { display:'序号',render:function(rowData,index){
	            	   return index+1;
	               },width:40},
	               { display: '航空公司', name: 'companyName', minWidth: 110 ,isSort:false},
	               { display: '航班编号', name: 'flightNo', minWidth: 70 ,isSort:false},
				   { display: '出发地', name: 'fromCityName', minWidth: 30 ,isSort:false},
	              /*  { display: '出发地编码', name: 'fromCity', minWidth: 50 ,isSort:false}, */
	               { display: '目的地', name: 'toCityName' ,isSort:false},
	             /*   { display: '目的地编码', name: 'toCity' ,isSort:false}, */
	              
	               { display: '起飞时间', name: 'flightStartTime',type:'date',isSort:true},
	               { display: '到达时间', name: 'flightEndTime',type:'date',isSort:true},
	               { display: '班次', name: 'frequence',minWidth: 50 ,isSort:true},      
	               { display: '入库时间', name: 'entryTime',minWidth: 133,isSort:false,
	            	   render: function (row)
	                    {  
	            		   if(row.entryTime !='' && row.entryTime != null){
	            			   var d = new Date(row.entryTime);   
							   return  formatDate(d);
	            		   }else{
	            			   return '';
	            		   }
	            		 
	               }},
	               { display: '班期', columns:
	                        [
	                         { display: '开始时间', name: 'effectStartTime' ,isSort:false},
	  	 	                 { display: '结束时间', name: 'effectEndTime' ,isSort:false} 
	                        ]
	                },               
	               { display: '区域',isSort:false, render: function (row)
	                    {
	            	    if(row.areaName&&row.areaName!=null){
	            	    	return row.areaName+"("+row.areaCode+")";
	            	    }else{
	            	    	return '';
	            	    }
            			
                   }}
	               ],
	     width: '100%',pageSizeOptions: [5, 10, 20, 30], height: '100%'
	});	
	
})
function loadGrid(data){
	var grid=$("#maingrid").ligerGrid({
			dataAction:'local',
	        enabledSort:true,    // 就否允许排序
	        data:data,
			dataType:"local"
		});
	
}

function loadAndDisplayData(grid,url){    
	if($('#depCity').val()!=''&&$('#arrCity').val()){
		//alert("");
		$.ajax({
	        url : url,
	        data:{
	        	'fromCityName':$('#depCity').val(),
	        	'toCityName':$('#arrCity').val(),	
	        	'companyCode':$('#carrier').val()
	        	},
	        cache : false, 
	        async : false,
	        type : "POST",
	       	complete: function(jqXHR, textStatus){
	       		if(jqXHR.status==200){
	       			result = parseObj(jqXHR.responseText);
	       			var data = result;
	       			
	       			loadGrid(data);
	       		}else{
	       			alert('查询失败,请与管理员联系');
	       		}
	       	}
	    });
	}
	FDCDialog.unLockWindow();
}

function changeAction(url){
	$('#channel').attr('action',url);
}


function checkForm(){
	if($('#depCity').val()=='中文/拼音' || $('#arrCity').val()=='中文/拼音'){
		window.confirm('航段没有选择，请选择航线!');
	        return false;
	}
	
	if($('#depCity').val()==$('#arrCity').val()){
		window.confirm('航段不能选择一样!');
        return false;
	}
	if($('#depCity').val()==''||$('#arrCity').val()==''){
		window.confirm('航段不能为空!');
        return false;
	}
	
	
	return true;
}

function checkJspForm(){

	if(!checkForm()){
		return false;
	}
 //	changeAction('flightInfoQueryAction!toAnalyseJSP.action');
	<%-- FDCDialog.lockWindow(true,'<%=request.getContextPath() %>'); --%>
	setTimeout(function(){loadAndDisplayData($('#maingrid'),'airlineAction!getData.action');},1);
}

</script>
</head>

<body>
	<div >
		<div class="form_table_tltle">查询条件</div>
		<form id="channel" name="channelForm" method="post"
			action="flightInfoQueryAction!analyse.action">
			<table cellSpacing=0 cellPadding=0 width="100%" border=0
				class="form_table">
				<TR>
					<TD height="26" class="left" style="text-align: left">航空公司：</TD>
					<TD><select name="vo.carrier" style="width: 150px;"
						id="carrier">
							<c:choose>
								<c:when test="${sourceLists == null}">
								</c:when>
								<c:otherwise>
									<c:forEach var="item" items="${sourceLists }">
										<c:if test="${item.webTyle==1 }">
											<c:choose>
												<c:when test="${not empty vo.carrier }">

												</c:when>
												<c:otherwise>
													<option value="${item.carrierKey}">${item.name}</option>
												</c:otherwise>

											</c:choose>


										</c:if>
									</c:forEach>
									<option value="" selected="selected"></option>
								</c:otherwise>
							</c:choose>
					</select>
					<TD class="left" style="text-align: left"></TD>
					<TD></TD>
				</TR>

				<TR>
					<TD width="120" height="26" class="left" style="text-align: left">航&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;段：</TD>
					<TD><input type="text" style="width: 100px" name="vo.fromCity"
						id="depCity" value="${vo.fromCity}" readonly="readonly"> <span>至</span>
							<input type="text" style="width: 100px" name="vo.toCity"
							id="arrCity" value="${vo.toCity}" readonly="readonly"> 
					<TD width="120" class="left" style="text-align: left"></TD>
					<TD></TD>
				</TR>
				
				<TR>
					<TD class="left" style="text-align: left"></TD>
					<TD><input type="button" onclick="javascript:checkJspForm();"
						value="" class="btn01" id="Submit2" /> <input type="reset"
						onclick="resetFunction('channel')" value="" class="btn02"
						id="Submit222" /></TD>
				</TR>
			</TABLE>
		</form>
		<div id="maingrid" style="margin-top: 10px;"></div>


	</div>
</body>
</html>
<style>
<!--
.l-grid-hd-cell-text {
	text-align: center;
	cursor: text;
}
-->
</style>






<%-- <%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>航线航班数据录入页面</title>
<link
	href="<%=request.getContextPath()%>/fare/js/ligerUI/skins/Aqua/css/ligerui-all.css"
	rel="stylesheet" type="text/css" />
<link
	href="<%=request.getContextPath()%>/fare/js/ligerUI/skins/ligerui-icons.css"
	rel="stylesheet" type="text/css" />


<link href="<%=request.getContextPath() %>/fare/js/ligerUI/skins/Gray/css/all.css" rel="stylesheet"
	type="text/css" />
<script
	src="<%=request.getContextPath()%>/fare/js/jquery/jquery-1.3.2.min.js"
	type="text/javascript"></script>
<script
	src="<%=request.getContextPath()%>/fare/js/ligerUI/js/core/base.js"
	type="text/javascript"></script>
<script
	src="<%=request.getContextPath()%>/fare/js/ligerUI/js/ligerui.min.js"
	type="text/javascript"></script>
<script
	src="<%=request.getContextPath()%>/fare/js/ligerUI/js/plugins/ligerDateEditor.js"
	type="text/javascript"></script>

<script
	src="<%=request.getContextPath()%>/fare/js/ligerUI/js/plugins/ligerToolBar.js"
	type="text/javascript"></script>
<script
	src="<%=request.getContextPath()%>/fare/js/ligerUI/js/plugins/ligerGrid.js"
	type="text/javascript"></script>
<script
	src="<%=request.getContextPath()%>/fare/js/ligerUI/js/plugins/ligerWindow.js"
	type="text/javascript"></script>
<script
	src="<%=request.getContextPath()%>/fare/js/ligerUI/js/plugins/ligerDialog.js"
	type="text/javascript"></script>
<script
	src="<%=request.getContextPath()%>/fare/js/ligerUI/js/plugins/ligerResizable.js"
	type="text/javascript"></script>
<link
	href='<%=request.getContextPath()%>/fare/js/cityquery/cityquery.css'
	rel="stylesheet" type="text/css" />
<script type='text/javascript'
	src='<%=request.getContextPath()%>/fare/js/cityquery/citylist.js'></script>
<script type='text/javascript'
	src='<%=request.getContextPath()%>/fare/js/cityquery/querycity2.js'></script>

<style type="text/css">
* {
	font-size: 12px;
}

select {
	width: 135px;
}

.table-edit { "
	width: 650px;
	height: 400px";
	cellpadding: 12px;
}

.table-edit tr td { "
	font-size: 16px;
	width: 60px;
	height: 12px;
	padding: 3px;
}

.l-table-edit-td {
	padding: 0 2px 0 0;
}

.r-table-edit-td {
	padding: 0 0 0 2px;
}

.combox {
	width: 132px;
}
</style>
<script type="text/javascript">
	//var datalist = ${showAllData};//获取Action传来的JSON数据;
	var selectedRow;
	$(function() {

		initGrid();
		//设置表单元素为日期选择控件 
		$("#departTime").ligerDateEditor({
			showTime : true,
			labelWidth : 10,
			labelAlign : 'center'
		});
		$('#fromSelect').querycity({
			'data' : citysFlight,
			'tabs' : labelFromcity,
			'hotList' : hotList
		});
		$('#destSelect').querycity({
			'data' : citysFlight,
			'tabs' : labelFromcity,
			'hotList' : hotList
		});

	});
	function initGrid() {
		$.ajax({//调用ajax异步请求数据 
			url : "airlineAction!getData.action",
			async : false,
			dataType : "json",
			success : function(data) {
				$("#maingrid").ligerGrid({
					height : '100%',
					width : '100%',
					columns : [ {
						display : '航空公司',
						name : 'company',
						//width : 80,
						height : 40,
						type : 'text'
					}, {
						display : '航线',
						columns : [ {
							display : '起点',
							name : 'source',
							align : 'center',
							width : 80
						}, {
							display : '终点',
							name : 'dest',
							width : 80,
							align : 'center'
						} ]

					}, {
						display : '航程',
						//width : 80,
						name : 'voyage',
					}, {
						display : '航班',
						name : 'fightNo',
						//	width : 80,
						//type : 'int',
						editor : {
							type : 'int'
						}
					}, {
						display : '起飞时间',
						name : 'departTime',
						type : 'date',
					//	width : 100,

					} ],
					data : data,
					pageSize : 20,
					rownumbers : true,
					toolbar : {
						items : [ {
							text : '增加',
							click : addRow,
							icon : 'add'
						}, {
							line : true
						}, {
							text : '修改',
							click : updateRow,
							icon : 'modify'
						}, {
							line : true
						}, {
							text : '删除',
							click : delRow,
							icon : 'delete'
						} ]
					},
				});
			}

		});
	}
	function addRow() {

		$("#flag").attr("value", "add");
		$("#id").attr("value", "");
		$("#fromSelect").attr("value", "");
		$("#destSelect").attr("value", "");
		$("#voyage").attr("value", "");
		$("#departTime").attr("value", "");
		$("#fightNo").attr("value", "");
		showWindow("添加记录");
	}

	function delRow() {
		var manager = $("#maingrid").ligerGetGridManager();
		selectedRow = manager.getSelectedRow();
		if (selectedRow == undefined) {//未选中记录 
			$.ligerDialog.error('请先选择待删除的数据项 ');
			return;
		}
		$.ligerDialog.confirm('确定删除该记录', true, function(yes, value) {
			if (yes) {
				$("#flag").attr("value", "delete");
				$("#id").attr("value", selectedRow.id);
				document.forms['myform'].submit();

			}
		})
	}

	function updateRow() {
		var manager = $("#maingrid").ligerGetGridManager();
		selectedRow = manager.getSelectedRow();
		if (selectedRow == undefined) {//未选中记录 
			$.ligerDialog.error('请先选择待更新的数据项 ');
			return;
		}
		$("#compSelect").attr("value", selectedRow.company);
		$("#flag").attr("value", "update");
		$("#id").attr("value", selectedRow.id);
		$("#fromSelect").attr("value", selectedRow.source);
		$("#destSelect").attr("value", selectedRow.dest);
		$("#voyage").attr("value", selectedRow.voyage);
		$("#departTime").attr("value", selectedRow.departTime);
		$("#fightNo").attr("value", selectedRow.fightNo);

		showWindow("更新记录");
	}
	function showWindow(title) {
		$("#editDictWindow").show();
		$.ligerDialog.open({
			title : title,
			width : 440,
			height : 360,
			//allowClose :false,
			target : $("#editDictWindow"),

		});

	}
	//验证表单数据非空
	function validate() {
		var reg;
		var  value1=$("#voyage").attr("value");
		var  value2=$("#fightNo").attr("value");
		if ($("#departTime").attr("value") == '') {
			$.ligerDialog.warn('起飞时间不能为空');
			return false;
		}
		if ($("#fightNo").attr("value") == '') {
			$.ligerDialog.warn('航班项不能为空');
			return false;
		}

		if ($("#voyage").attr("value") == '') {
			$.ligerDialog.warn('航程项不能为空');
			return false;
		}

		reg = /^\d+$/;//正则表达式验证输入值为数字
		if(!value1.match(reg)){
			$.ligerDialog.warn('航程项只能是数字');
			return false;
		}
		
		reg = /^[a-zA-Z]+\d+$/;//正则表达式验证输入值为字母开头数字结束
		if(!value2.match(reg)){
			$.ligerDialog.warn('航班项必须以字母开头数字结束');
			return false;
		}
	
		return true;//字段格式正确，可以提交表单

	}
</script>
</head>

<body>
	
	<div id="maingrid" style="margin: 10px 0 0 20px"></div>

	<div id="editDictWindow" style="display: none;">
		<form name="myform" method="post" onsubmit="return validate();" action="airlineAction!doSave.action">
			<input type="hidden" id="id" name="vo.id" /> <input type="hidden" id="flag" name="flag" />

			<table class="table-edit">

				<tr>
					<td class="l-table-edit-td">航空公司:</td>
					<td class="l-table-edit-td"><select name="vo.company"
						id="compSelect">
							<option value="南方航空公司">南方航空公司</option>
							<option value="国际航空公司">国际航空公司</option>
							<option value="东方航空公司">东方航空公司</option>
							<option value="海南航空公司">海南航空公司</option>

					</select></td>
				</tr>

				<tr>
					<td class="l-table-edit-td">航线起点:</td>
					<td class="l-table-edit-td"><input class="combox" type="text"
						name="vo.source" id="fromSelect"></td>
					<td class="r-table-edit-td">航线终点:</td>
					<td class=""><input class="combox" type="text" name="vo.dest"
						id="destSelect"></td>
					</td>
				</tr>
				<tr>
					<td class="l-table-edit-td">起飞时间:</td>
					<td class="l-table-edit-td"><input class="combox" type="text"
						id="departTime" name="vo.departTime" /></td>
				</tr>
				<tr>
					<td class="l-table-edit-td">航程:</td>
					<td class="l-table-edit-td"><input class="combox" type="text"
						id="voyage" name="vo.voyage" required="required" /></td>
					<td class="r-table-edit-td">航班:</td>
					<td class="r-table-edit-td"><input class="combox" type="text"
						id="fightNo" name="vo.fightNo" required="required" /></td>
				</tr>
				<tr>
					<td></td>
				</tr>
				<tr style="magin: 20px 0 0 0">
					<td class="l-table-edit-td" align="center" colspan="4" rowspan="2"><input
						class="l-button l-button-submit" type="submit" value="保存" /></td>
				</tr>
			</table>
		</form>
	</div>
</body>
</html> --%>